def index():
    config_name = 'sip'
    sip_config = ['appkey', 'secret', 'url', 'v']
    query = (db.config.name == config_name)
    
    form = db().select(db.config.ALL)
#    config = db(query).select('appkey', 'v', 'secret', 'url')
    config = db(query).select()
    
    response.flash = config[0].v
    return dict(
        form = SQLTABLE(form),\
        type = type(config)
        )

def new():
    form = SQLFORM(db.config, fields=['name','appkey','secret','url','v'])
    if form.accepts(request.vars, session):
        redirect(URL(r=request,f='index'))
    return dict(
        form = form,
        )
